import jdk.nashorn.internal.objects.NativeError;

import java.util.InputMismatchException;
import java.util.Scanner;

public class FinallyTest {
    public static int getData(){
Scanner sc = null;
try{
sc = new Scanner(System.in);
int data = sc.nextInt();
return data;
}catch (InputMismatchException e){
e.printStackTrace();
}finally {
System.out.println("finally中代码");
}
System.out.println("try-catch-finally之后代码");
if(null != sc){
sc.close();
}
return 0;
}

public static void main(String[] args) {
int data = getData();
System.out.println(data);
}
//    public static void main(String[] args) {
//        int[] arr = {1,2,3};
//        try{
//            System.out.println(arr[10]);
//        } catch (NullPointerException e){
//            e.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        System.out.println("catch之后");
//    }
//    public static int getData(){
//        Scanner sc = null;
//try{
//Scanner scanner = new Scanner(System.in);
//    sc = new Scanner(System.in);
//int data = sc.nextInt();
//return data;
//}catch (InputMismatchException e){
//e.printStackTrace();
//}finally {
//System.out.println("finally中代码");
//}
//System.out.println("try-catch-finally之后代码");
//if(null != sc){
//sc.close();
//}
//
//
//return 0;
//}
//public static void main(String[] args) {
//int data = getData();
//System.out.println(data);
//}
// 下面程序输出什么？
//public static void main(String[] args) {
//System.out.println(func());
//}
//    public static int func() {
//try {
//return 10;
//}
//finally {
//return 20;
//}
//    }
}
